package com.longge;

import java.util.Map;
import java.util.TreeMap;

/**
 * @创建人 xinglongge
 * @创建时间 2021/12/2
 * @描述
 */
public class FindRelativeRanks {
    public String[] findRelativeRanks(int[] score) {

        TreeMap<Integer, Integer> map = new TreeMap<>((o1, o2) -> o2 - o1);

        String[] res = new String[score.length];
        for (int i = 0; i < score.length; i++) {
            map.put(score[i], i);
        }
        int i = 0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            if (i == 0) {
                res[entry.getValue()] = "Gold Medal";
            } else if (i == 1) {
                res[entry.getValue()] = "Silver Medal";
            } else if (i == 2) {
                res[entry.getValue()] = "Bronze Medal";
            } else {
                res[entry.getValue()] = String.valueOf(i+1);
            }
            i++;
        }

        return res;
    }
}
